package cn.itlaobing.dao;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

/**
 * 类名: cn.itlaobing.dao
 * 功能:  轮播图数据访问
 * 作者: 王博
 * 日期: 2017/11/14 14:14
 */
public class ItlbFocussDao extends BaseDao {
    /*
        获取轮播图的图片地址
     */
    public List<Object> gainImgURL() throws SQLException {
        String sql="select img from itlb_focuss order by weight asc limit 0,4";
        QueryRunner qr=new QueryRunner(getDataSource());
        return qr.query(sql, new ResultSetHandler<List<Object>>() {
            @Override
            public List<Object> handle(ResultSet resultSet) throws SQLException {
                List<Object> listobj=new ArrayList<Object>();
                while(resultSet.next()){
                    listobj.add(resultSet.getObject(1));
                }
                return listobj;
            }
        });
    }
}
